<template>
    <div class="indexs">
        <div class="heads_warp">
            <div class="heads">
                <div class="fr">
                    <div class="fl logres" v-if="!session">
                        <router-link to="/login">登录</router-link>
                        <router-link to="/resgister">注册</router-link>
                    </div>
                     <!-- <div >
                       {{uname}}
                    </div> -->
                          
        <el-dropdown trigger="hover" class="fl logres" v-if="session">
          <span class="el-dropdown-link userinfo1-inner">
            {{u_name}}
            <img v-if="sex" src="http://127.0.0.1:8081/upload/timg.jpg">
            <img v-if="!sex" src="http://127.0.0.1:8081/upload/timg (1).jpg">
            
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="xiaoxi">我的消息</el-dropdown-item>
            <el-dropdown-item command="set">设置</el-dropdown-item>
            <el-dropdown-item command="return" divided @click.native="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
                    <span class="fl k_line"></span>
                    <div class="fl help">
                        <router-link to="/help">帮助中心</router-link>
                    </div>
                </div>
            </div>

        </div>
           <div class="content_warp">
               <router-view name="index"></router-view></div> 
        </div>
        
</template>

<script>
import {mapState,mapMutations,mapActions,mapGetters} from "vuex";
export default {
data () {
    return {
        session:false,
        u_name:"",
        sex:""
      
    }
},
methods: {
    ...mapActions(["set","get"]),
    logout()
    {
       let that = this;
      this.$confirm("确认退出吗?", "提示", {}).then(() => {
        sessionStorage.removeItem("username");
        sessionStorage.removeItem("userid");
       sessionStorage.removeItem("usersex");
        that.$router.push("/login");
      }); 
    },
},
computed: {
  ...mapState(["uname","upwd","uhidd"])  
},
mounted () {
    let user = sessionStorage.getItem("username");
    if(sessionStorage.getItem("usersex")=="1")
    {
        this.sex=true;
    }
    else{
        this.sex=false;
    }
    // this.sex=sessionStorage.getItem("usersex");
    if (user) {
      this.u_name = user;
      this.session=true;
    }
  
    
}
}
</script>

<style>
a{
    text-decoration: none
}
.heads_warp{
    width: 100%;
    height: 60px;
    background: #333;
}
.heads_warp .heads{
    width: 1080px;
    margin: 0 auto;
    /* background: pink; */
    height: 100%;
}
.heads_warp .heads .fr{
    float: right;
    padding-right: 100px
}
.heads::after,.fr::after{
    content: "";
    clear: both;
    display: block;
    overflow: hidden;
    visibility: hidden;
    height: 0;
}
.logres,.help{
    line-height: 60px;
    color: #fff;
}
.logres a,.help a{
    padding: 0 5px;
    color: #f1f1f1
}
.fl a:hover{
    color: #fff
}
.fl{
    float: left;
}
 .k_line{
    border-color: #666;
    margin: 19px 7px 0 13px;
     display: inline-block;
    height: 23px;
    vertical-align: middle;
    border-right: 1px solid #e7e7e7;
}
.userinfo1-inner {
  cursor: pointer;
  color: #fff;
}
.userinfo1-inner img {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  margin: 10px 0px 10px 10px;
  float: right;
  overflow: hidden;
}
.sear_warp{
   
}

a,input,button{
outline:none;
}
</style>
